#ifndef ADDRESSFORMAT_H_
#define ADDRESSFORMAT_H_

class AddressFormat {

private:
	uint64_t m_addr;
	uint32_t m_offset;
	uint16_t m_segID;
	uint32_t m_dataSize;

public:
	AddressFormat(uint64_t addr) {
	
		m_addr = addr;
		m_offset = addr >> 32;
		m_segID = addr & 0xFFFF;
		m_dataSize = (addr & 0xFFFF0000)>>16;
	}

	AddressFormat(uint16_t segmentID, uint32_t offset, uint32_t dataSize) {
		 
		m_offset = offset;
		m_segID = segmentID;
		m_dataSize = dataSize;
		m_addr = composeAddress(m_segID, m_offset, m_dataSize);
	}

	uint64_t getAddr()   {return m_addr;  }
	uint32_t getOffset()  {return m_offset;}
	uint16_t getSegID()  {return m_segID; }
	uint16_t getDataSize() {return m_dataSize;}

	uint64_t composeAddress(uint16_t segmentID, uint32_t offset, uint32_t dataSize) { 
	
        if(dataSize > 0xFFFF ) {
            return (segmentID | ((uint64_t)offset << 32));
        } else {
            return (segmentID | ((uint64_t)offset << 32) | ((uint64_t)dataSize << 16));
        }
    }	
};

#endif
